#!/bin/bash

option=$1

if test ! -z $option ; then
	if test $option = "-c" ; then
        rm -rf INSTALL
        rm -rf freetype-2.12.0
        exit 0
    else
        OS_NAME=$option
	fi
fi

if test ! -d freetype-2.12.0 ; then
    tar xvfz freetype-2.12.0.tar.gz
fi

cd freetype-2.12.0

# 不需要依赖zlib和png库

if test $OS_NAME = "alios" ; then
    ./configure CC=arm-none-eabi-gcc --host=arm-none --prefix=$PWD/../INSTALL --with-zlib=no --with-png=no LDFLAGS=--specs=nosys.specs
elif test $OS_NAME = "rtt" ; then
    ./configure CC=arm-anykav500-eabi-gcc --host=arm-none --prefix=$PWD/../INSTALL --with-zlib=no --with-png=no CFLAGS="-O2 -mcpu=arm926ej-s -std=c99 -mlittle-endian -fno-short-enums -mfloat-abi=soft -mno-unaligned-access" LDFLAGS="--specs=nosys.specs -O2"
else
    ./configure CC=arm-anykav500-linux-uclibcgnueabi-gcc --host=arm-linux --prefix=$PWD/../INSTALL --with-zlib=no --with-png=no
fi

make clean
make
make install

cd -